from cryptography.fernet import Fernet

# 生成密钥
key = Fernet.generate_key()

# 将密钥写入文件
with open('secret.key', 'wb') as key_file:
    key_file.write(key)

print("密钥已生成并保存到 'secret.key'")
